﻿using System;
using System.Collections.Generic;
using System.Linq;
using DBHelper;
using System.Data;
using System.Data.SqlClient;
using BusinessLayer.FindArtInfo.Models;

namespace BusinessLayer.FindArtInfo
{
    public class MonogramTextBL
    {
        public List<MonogramTextDetailExtend> Search(string keyWord, int pageIndex, int pageSize, out int totalRecord)
        {
            totalRecord = 0;
            List<MonogramTextDetailExtend> result = new List<MonogramTextDetailExtend>();
            var adapter = new BaseDAO(DbConfig.DbFindArtInfoConnectionString);
            adapter.AddParameter("@KeyWord", keyWord);
            adapter.AddParameter("@PageIndex", pageIndex);
            adapter.AddParameter("@PageSize", pageSize);
            var output = adapter.AddParameter("@TotalRecord", SqlDbType.Int, ParameterDirection.Output);            
            try
            {
                result = adapter.GetList<MonogramTextDetailExtend>("sp_Monogram_Search", CommandType.StoredProcedure, CustomConnectionState.KeepOpen);
                totalRecord = Convert.ToInt32(output.Value);
                return result;
            }
            catch (Exception)
            {
            }
            finally { adapter.Dispose(); }
            return result;
        }
    }
}
